package cn.cstech.aijia.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import cn.cstech.aijia.R;

/**
 * Created by xi on 15/9/12.
 */
public class CompanyListAdapter extends BaseAdapter {

    private Context context;
    private List<String> list;
    private LayoutInflater mInflater;
    public CompanyListAdapter(Context context, List<String> list){
        this.mInflater = LayoutInflater.from(context);
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        Holder holder;
        if(convertView == null){
            holder = new Holder();
            convertView = mInflater.inflate(R.layout.adapter_company_list,null);
            convertView.setTag(holder);
        }else{
            holder = (Holder)convertView.getTag();
        }

        return convertView;
    }



    public final class  Holder {

        ImageView icon_iv;
        TextView name_tv;
        TextView company_tv;
        TextView num_tv;
        TextView price_tv;
        TextView distance_tv;
        ImageView score_tv;
    }


    public void setData(List<String> list){

        this.list = list;
        notifyDataSetChanged();

    }
}
